package com.cy.pj.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@NoArgsConstructor
@Data
public class JsonResult implements Serializable {

    private static final long serialVersionUID = 2084959916244298530L;
    private Integer state=1;  //状态码设计
    private String message ="ok"; //状态信息
    private Object data; //查询响应结果
    //提供状态信息
    public JsonResult (String message){
        this.message=message;
    }
//    提供响应信息
    public JsonResult(Object data){
        this.data=data;
    }
    public JsonResult(Integer state,String message){
        this.state=1;
        this.message=message;
    }

    public JsonResult(Integer state,String message,Object data){
        this.state=0;
        this.message=message;
        this.data=data;
    }

    //提供错误信息
    public JsonResult(Throwable e){
        this.state=0;
        this.message=e.getMessage();
    }
}
